/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.listener;

import com.minierp.bean.UserBean;
import com.minierp.dao.AdjustBillDao;
import com.minierp.dao.BaseDao;
import com.minierp.dao.BusinessBillDao;
import com.minierp.dao.CooperBillDao;
import com.minierp.dao.EnterpriseInfoDao;
import com.minierp.dao.EstablishmentCommunicateDao;
import com.minierp.dao.EstablishmentDao;
import com.minierp.dao.FeeBillDao;
import com.minierp.dao.IdGenerator;
import com.minierp.dao.IncomeBillDao;
import com.minierp.dao.LoanBillDao;
import com.minierp.dao.PayBillDao;
import com.minierp.dao.PurchaseBillDao;
import com.minierp.dao.ReceiveBillDao;
import com.minierp.dao.SmsAlertDao;
import com.minierp.dao.StafferDao;
import com.minierp.dao.TransferBillDao;
import com.minierp.dao.UserDao;
import com.minierp.dao.UserPoDao;
import com.minierp.helper.EncCommonHelper;
import com.minierp.helper.PageHelper;
import com.minierp.model.EnterpriseInfo;
import com.minierp.model.EstablishmentCommunicate;
import com.minierp.model.SmsAlert;
import com.minierp.model.Staffer;
import com.minierp.model.User;
import com.minierp.model.UserPo;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.springframework.web.context.WebApplicationContext;

class SmsAletThread extends Thread {
	private boolean runFlag = true;
	private IdGenerator idGenerator;
	private BusinessBillDao businessBillDao;
	private SmsAlertDao smsAlertDao;
	private EstablishmentDao establishmentDao;
	private ReceiveBillDao receiveBillDao;
	private IncomeBillDao incomeBillDao;
	private PayBillDao payBillDao;
	private PurchaseBillDao purchaseBillDao;
	private FeeBillDao feeBillDao;
	private AdjustBillDao adjustBillDao;
	private TransferBillDao transferBillDao;
	private LoanBillDao loanBillDao;
	private CooperBillDao cooperBillDao;
	private UserDao userDao;
	private UserPoDao userPoDao;
	private EstablishmentCommunicateDao establishmentCommunicateDao;
	private StafferDao stafferDao;
	private EnterpriseInfoDao enterpriseInfoDao;

	public SmsAletThread(WebApplicationContext wac) {
		this.businessBillDao = (BusinessBillDao) wac.getBean("businessBillDao");
		this.smsAlertDao = (SmsAlertDao) wac.getBean("smsAlertDao");
		this.establishmentDao = (EstablishmentDao) wac
				.getBean("establishmentDao");
		this.receiveBillDao = (ReceiveBillDao) wac.getBean("receiveBillDao");
		this.incomeBillDao = (IncomeBillDao) wac.getBean("incomeBillDao");
		this.payBillDao = (PayBillDao) wac.getBean("payBillDao");
		this.purchaseBillDao = (PurchaseBillDao) wac.getBean("purchaseBillDao");
		this.feeBillDao = (FeeBillDao) wac.getBean("feeBillDao");
		this.adjustBillDao = (AdjustBillDao) wac.getBean("adjustBillDao");
		this.transferBillDao = (TransferBillDao) wac.getBean("transferBillDao");
		this.loanBillDao = (LoanBillDao) wac.getBean("loanBillDao");
		this.cooperBillDao = (CooperBillDao) wac.getBean("cooperBillDao");
		this.userDao = (UserDao) wac.getBean("userDao");
		this.userPoDao = (UserPoDao) wac.getBean("userPoDao");
		this.idGenerator = (IdGenerator) wac.getBean("idGenerator");
		this.establishmentCommunicateDao = (EstablishmentCommunicateDao) wac
				.getBean("establishmentCommunicateDao");
		this.stafferDao = (StafferDao) wac.getBean("stafferDao");
		this.enterpriseInfoDao = (EnterpriseInfoDao) wac
				.getBean("enterpriseInfoDao");
	}

	public void setRunFlag(boolean runFlag) {
		this.runFlag = runFlag;
	}

	public void run() {
		EnterpriseInfo ent = this.enterpriseInfoDao.get();
		String smsSign = "";
		if (ent.getShortName() != null && !ent.getShortName().equals("")) {
			smsSign = ent.getShortName();
		}

		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
		SimpleDateFormat longEnSf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		SimpleDateFormat longCnSf = new SimpleDateFormat("yyyy年MM月dd日");
		SimpleDateFormat shortCnSf = new SimpleDateFormat("MM月dd日");
		SimpleDateFormat shortEnSf = new SimpleDateFormat("MM-dd HH:mm");
		Calendar c = Calendar.getInstance();

		while (this.runFlag) {
			EncCommonHelper.debug("************sms alert:thread start...");
			boolean canSms = false;
			if (PageHelper.getSmsBalance() > 0.0D) {
				canSms = true;
			}

			try {
				Date e = new Date();
				List alertList = this.smsAlertDao.getList();
				int commList = 0;

				label658 : while (true) {
					String content;
					List arg46;
					int arg48;
					if (commList >= alertList.size()) {
						if (!canSms) {
							break;
						}

						List arg42 = this.establishmentCommunicateDao
								.getSmsList();
						if (arg42.size() <= 0) {
							break;
						}

						List arg43 = this.stafferDao.getSmsList();
						int arg44 = 0;

						while (true) {
							if (arg44 >= arg42.size()) {
								break label658;
							}

							EstablishmentCommunicate arg45 = (EstablishmentCommunicate) arg42
									.get(arg44);
							if (arg45.getSmsRemindDate() != null
									&& arg45.getSmsRemindDate().before(e)) {
								content = shortEnSf.format(arg45
										.getCommunicateTime())
										+ " "
										+ arg45.getTitle()
										+ "["
										+ arg45.getCreaterName() + "]";
								if (arg45.getForAll().equals("Y")) {
									for (int arg49 = 0; arg49 < arg43.size(); ++arg49) {
										Staffer arg52 = (Staffer) arg43
												.get(arg49);
										PageHelper.sendSms(arg52.getMobile(),
												arg52.getStafferName(),
												content, smsSign,
												this.smsAlertDao,
												this.idGenerator);
									}
								} else {
									arg46 = this.establishmentCommunicateDao
											.getReceiverList(arg45.getId());
									boolean arg53 = false;

									for (arg48 = 0; arg48 < arg46.size(); ++arg48) {
										Object[] arg55 = (Object[]) arg46
												.get(arg48);
										Staffer arg62 = (Staffer) arg55[1];
										if (arg62.getId() == arg45
												.getCreaterId()) {
											arg53 = true;
										}

										PageHelper.sendSms(arg62.getMobile(),
												arg62.getStafferName(),
												content, smsSign,
												this.smsAlertDao,
												this.idGenerator);
									}

									if (!arg53) {
										Staffer arg60 = (Staffer) this.establishmentCommunicateDao
												.get(Staffer.class,
														arg45.getCreaterId());
										if (arg60 != null) {
											PageHelper.sendSms(
													arg60.getMobile(),
													arg60.getStafferName(),
													content, smsSign,
													this.smsAlertDao,
													this.idGenerator);
										}
									}
								}

								arg45.setSendSms("N");
								this.establishmentCommunicateDao.update(arg45);
							}

							++arg44;
						}
					}

					SmsAlert stafferList = (SmsAlert) alertList.get(commList);
					if (stafferList.getStatus() != null
							&& stafferList.getStatus().equals("Y")) {
						String i = stafferList.getType();
						if (i == null) {
							i = "";
						}

						boolean ec = false;
						content = stafferList.getPtType();
						if (content == null) {
							content = "";
						}

						Date recList;
						if (content.equals("TIME")) {
							recList = longEnSf.parse(sf.format(e) + " "
									+ stafferList.getPtHour() + ":"
									+ stafferList.getPtMinute());
							if ((stafferList.getLastCheck() == null || !stafferList
									.getLastCheck().equals(sf.format(e)))
									&& recList.before(e)) {
								ec = true;
							}
						} else if (content.equals("CYCLE")) {
							if (stafferList.getLastCheck() == null) {
								ec = true;
							} else {
								recList = longEnSf.parse(stafferList
										.getLastCheck());
								c.setTime(recList);
								c.add(12, stafferList.getAlertCycle());
								if (c.getTime().before(e)) {
									ec = true;
								}
							}
						}

						if (ec) {
							Object[] objs;
							String s1;
							int arg54;
							if (i.equals("CLIENT_CREDIT") && canSms) {
								EncCommonHelper
										.debug("************sms alert:counting client credit...");
								c.setTime(e);
								c.add(5, 0 - stafferList.getAlertCycle());
								recList = c.getTime();
								List arg50 = this.businessBillDao
										.getSmsReceivableList(recList);

								for (arg54 = 0; arg54 < arg50.size(); ++arg54) {
									objs = (Object[]) arg50.get(arg54);
									if (objs[1] != null
											&& PageHelper.isMobileCode(objs[1]
													.toString())) {
										BigDecimal arg57 = (new BigDecimal(
												objs[2].toString())).subtract(
												new BigDecimal(objs[3]
														.toString())).add(
												new BigDecimal(objs[4]
														.toString()));
										s1 = "感谢" + objs[6].toString()
												+ "对我司的大力支持，贵单位的应付款项已达" + arg57
												+ "元。"
												+ stafferList.getCustomTxt();
										PageHelper.sendSms(objs[1].toString(),
												objs[0].toString(), s1,
												smsSign, this.smsAlertDao,
												this.idGenerator);
										this.establishmentDao.update(Long
												.parseLong(objs[5].toString()),
												e);
									}
								}
							} else {
								Date foundCreater;
								String needCodeExt;
								String content1;
								if (i.equals("BUS_REPORT")) {
									EncCommonHelper
											.debug("************sms alert:counting bus report...");
									recList = sf.parse(sf.format(e));
									c.setTime(recList);
									c.add(5, 1);
									foundCreater = c.getTime();
									List s = this.businessBillDao.getSmsCost(
											recList, foundCreater);
									String tmpArr = "0";
									s1 = "0";
									BigDecimal sta = new BigDecimal(0);
									BigDecimal tsIdArr = new BigDecimal(0);
									BigDecimal str = new BigDecimal(0);

									for (int codeStr = 0; codeStr < s.size(); ++codeStr) {
										objs = (Object[]) s.get(codeStr);
										if (objs[4].toString().equals("Y")) {
											tmpArr = objs[0].toString();
											sta = (BigDecimal) objs[1];
											sta = sta.add((BigDecimal) objs[2])
													.setScale(0, 4);
											str = (BigDecimal) objs[3];
										} else {
											s1 = objs[0].toString();
											tsIdArr = (BigDecimal) objs[1];
										}
									}

									BigDecimal arg67 = this.receiveBillDao
											.getSmsCost(recList, foundCreater);
									needCodeExt = arg67.add(str).setScale(0, 4)
											.toString();
									String maxIndex = this.incomeBillDao
											.getSmsCost(recList, foundCreater)
											.setScale(0, 4).toString();
									BigDecimal billList = this.payBillDao
											.getSmsCost(recList, foundCreater,
													"PURCHASE");
									BigDecimal loanInCount = this.purchaseBillDao
											.getSmsImprest(recList,
													foundCreater, "BUY");
									BigDecimal loanOutCount = this.purchaseBillDao
											.getSmsImprest(recList,
													foundCreater, "BACK");
									content1 = billList.add(loanInCount)
											.subtract(loanOutCount).toString();
									BigDecimal k = this.payBillDao.getSmsCost(
											recList, foundCreater, "COOPER");
									BigDecimal tmpObjs = this.cooperBillDao
											.getSmsImprest(recList,
													foundCreater);
									String cooCost = k.add(tmpObjs)
											.setScale(0, 4).toString();
									String feeCost = this.feeBillDao
											.getSmsCost(recList, foundCreater)
											.setScale(0, 4).toString();
									String content2 = shortCnSf.format(e) + "："
											+ "接单（" + tmpArr + "笔/" + sta
											+ "元），接单未审核（" + s1 + "笔/" + tsIdArr
											+ "元），收入（销售" + needCodeExt + "/其他"
											+ maxIndex + "），支出（采购" + content1
											+ "/外协" + cooCost + "/费用" + feeCost
											+ "）";
									List recList1 = this.smsAlertDao
											.getReceiverList(stafferList
													.getId());

									for (int j = 0; j < recList1.size(); ++j) {
										Staffer sta1 = (Staffer) ((Object[]) recList1
												.get(j))[1];
										this.createSystemMessage(sta1,
												longCnSf.format(e) + "营业简报",
												content2, this.businessBillDao,
												this.idGenerator);
										if (stafferList.getSmsFlag()
												.equals("Y") && canSms) {
											PageHelper.sendSms(
													sta1.getMobile(),
													sta1.getStafferName(),
													content2, smsSign,
													this.smsAlertDao,
													this.idGenerator);
										}
									}
								} else if (i.equals("BUS_TIMEOUT")) {
									EncCommonHelper
											.debug("************sms alert:counting bus timeout...");
									recList = sf.parse(sf.format(e));
									c.setTime(recList);
									c.add(5, 1);
									foundCreater = c.getTime();
									arg48 = this.businessBillDao
											.getSmsCompleteTimeout(foundCreater);
									arg54 = this.businessBillDao
											.getSmsDeliverTimeout(foundCreater);
									s1 = "截止" + shortCnSf.format(e) + "：超期未完工"
											+ arg48 + "笔，超期未送货" + arg54 + "笔";
									List arg58 = this.smsAlertDao
											.getReceiverList(stafferList
													.getId());

									for (int arg61 = 0; arg61 < arg58.size(); ++arg61) {
										Staffer arg64 = (Staffer) ((Object[]) arg58
												.get(arg61))[1];
										this.createSystemMessage(arg64, "截止"
												+ shortCnSf.format(e)
												+ "：超期未完工" + arg48 + "笔，超期未送货"
												+ arg54 + "笔", s1,
												this.businessBillDao,
												this.idGenerator);
										if (stafferList.getSmsFlag()
												.equals("Y") && canSms) {
											PageHelper.sendSms(
													arg64.getMobile(),
													arg64.getStafferName(), s1,
													smsSign, this.smsAlertDao,
													this.idGenerator);
										}
									}
								} else {
									User arg47;
									long arg51;
									int arg56;
									Staffer arg59;
									List arg63;
									long[] arg65;
									String arg66;
									byte arg68;
									int arg69;
									if (i.equals("BUS_EXAMINE")) {
										arg46 = this.smsAlertDao
												.getReceiverList(stafferList
														.getId());
										arg47 = this.userDao.getAdmin();
										arg51 = 0L;
										if (arg47 != null) {
											arg51 = arg47.getStafferId();
										}

										for (arg56 = 0; arg56 < arg46.size(); ++arg56) {
											arg59 = (Staffer) ((Object[]) arg46
													.get(arg56))[1];
											if (arg51 != arg59.getId()) {
												arg65 = this.getTsIdArr(arg59
														.getId());
												arg63 = this.businessBillDao
														.getExamSmsCount(arg65);
											} else {
												arg63 = this.businessBillDao
														.getExamSmsCount();
											}

											if (arg63.size() > 0) {
												arg66 = "";
												arg68 = 10;

												for (arg69 = 0; arg69 < arg68; ++arg69) {
													if (arg69 < arg63.size()) {
														if (!arg66.equals("")) {
															arg66 = arg66 + "、";
														}

														arg66 = arg66
																+ arg63.get(arg69);
													}
												}

												if (arg63.size() > arg68) {
													arg66 = arg66 + "......";
												}

												arg66 = "（" + arg66 + "）";
												needCodeExt = arg59
														.getStafferName()
														+ "：有"
														+ arg63.size()
														+ "张新业务单等待你审核";
												this.createSystemMessage(
														arg59,
														shortEnSf.format(e)
																+ " 有"
																+ arg63.size()
																+ "张新业务单待审核",
														needCodeExt
																+ arg66
																+ "["
																+ shortEnSf
																		.format(e)
																+ "]",
														this.businessBillDao,
														this.idGenerator);
												if (stafferList.getSmsFlag()
														.equals("Y") && canSms) {
													PageHelper
															.sendSms(
																	arg59.getMobile(),
																	arg59.getStafferName(),
																	needCodeExt
																			+ "["
																			+ shortEnSf
																					.format(e)
																			+ "]",
																	smsSign,
																	this.smsAlertDao,
																	this.idGenerator);
												}
											}
										}

										this.businessBillDao.updateExamSms();
									} else if (i.equals("BUS_MAKE")) {
										arg46 = this.smsAlertDao
												.getReceiverList(stafferList
														.getId());
										arg47 = this.userDao.getAdmin();
										arg51 = 0L;
										if (arg47 != null) {
											arg51 = arg47.getStafferId();
										}

										for (arg56 = 0; arg56 < arg46.size(); ++arg56) {
											arg59 = (Staffer) ((Object[]) arg46
													.get(arg56))[1];
											if (arg51 != arg59.getId()) {
												arg65 = this.getTsIdArr(arg59
														.getId());
												if (ent.getWorkCenter().equals(
														"Y")) {
													long[] arg70 = this
															.getWcIdArr(arg59
																	.getId());
													arg63 = this.businessBillDao
															.getMakeSmsCount(
																	arg65,
																	arg70);
												} else {
													arg63 = this.businessBillDao
															.getMakeSmsCount(arg65);
												}
											} else {
												arg63 = this.businessBillDao
														.getMakeSmsCount();
											}

											if (arg63.size() > 0) {
												arg66 = "";
												arg68 = 10;

												for (arg69 = 0; arg69 < arg68; ++arg69) {
													if (arg69 < arg63.size()) {
														if (!arg66.equals("")) {
															arg66 = arg66 + "、";
														}

														arg66 = arg66
																+ arg63.get(arg69);
													}
												}

												if (arg63.size() > arg68) {
													arg66 = arg66 + "......";
												}

												arg66 = "（" + arg66 + "）";
												needCodeExt = arg59
														.getStafferName()
														+ "：有"
														+ arg63.size()
														+ "张新业务单需要制作";
												this.createSystemMessage(
														arg59,
														shortEnSf.format(e)
																+ " 有"
																+ arg63.size()
																+ "张新业务单需要制作",
														needCodeExt
																+ arg66
																+ "["
																+ shortEnSf
																		.format(e)
																+ "]",
														this.businessBillDao,
														this.idGenerator);
												if (stafferList.getSmsFlag()
														.equals("Y") && canSms) {
													PageHelper
															.sendSms(
																	arg59.getMobile(),
																	arg59.getStafferName(),
																	needCodeExt
																			+ "["
																			+ shortEnSf
																					.format(e)
																			+ "]",
																	smsSign,
																	this.smsAlertDao,
																	this.idGenerator);
												}
											}
										}

										this.businessBillDao.updateMakeSms();
									} else if (i.equals("FIN_EXAM")) {
										arg46 = this.smsAlertDao
												.getReceiverList(stafferList
														.getId());
										arg47 = this.userDao.getAdmin();
										arg51 = 0L;
										if (arg47 != null) {
											arg51 = arg47.getStafferId();
										}

										for (arg56 = 0; arg56 < arg46.size(); ++arg56) {
											arg59 = (Staffer) ((Object[]) arg46
													.get(arg56))[1];
											long[] arg71 = (long[]) null;
											if (arg51 != arg59.getId()) {
												arg71 = this.getTsIdArr(arg59
														.getId());
											}

											arg66 = "";
											String arg72 = "";
											boolean arg74 = true;
											int arg73 = 10;
											List arg75;
											if (arg51 != arg59.getId()) {
												arg75 = this.receiveBillDao
														.getExamSmsCount(arg71);
											} else {
												arg75 = this.receiveBillDao
														.getExamSmsCount();
											}

											int arg76;
											if (arg75.size() > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg75.size()
														+ "张新收款单";

												for (arg76 = 0; arg76 < arg73; ++arg76) {
													if (arg76 < arg75.size()) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg75.get(arg76);
													}
												}

												if (arg74
														&& arg75.size() > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												arg73 -= arg75.size();
											}

											if (arg51 != arg59.getId()) {
												arg75 = this.payBillDao
														.getExamSmsCount(arg71);
											} else {
												arg75 = this.payBillDao
														.getExamSmsCount();
											}

											if (arg75.size() > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg75.size()
														+ "张新付款单";

												for (arg76 = 0; arg76 < arg73; ++arg76) {
													if (arg76 < arg75.size()) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg75.get(arg76);
													}
												}

												if (arg74
														&& arg75.size() > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												arg73 -= arg75.size();
											}

											if (arg51 != arg59.getId()) {
												arg75 = this.feeBillDao
														.getExamSmsCount(arg71);
											} else {
												arg75 = this.feeBillDao
														.getExamSmsCount();
											}

											if (arg75.size() > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg75.size()
														+ "张新费用单";

												for (arg76 = 0; arg76 < arg73; ++arg76) {
													if (arg76 < arg75.size()) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg75.get(arg76);
													}
												}

												if (arg74
														&& arg75.size() > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												arg73 -= arg75.size();
											}

											if (arg51 != arg59.getId()) {
												arg75 = this.incomeBillDao
														.getExamSmsCount(arg71);
											} else {
												arg75 = this.incomeBillDao
														.getExamSmsCount();
											}

											if (arg75.size() > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg75.size()
														+ "张新其他收入单";

												for (arg76 = 0; arg76 < arg73; ++arg76) {
													if (arg76 < arg75.size()) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg75.get(arg76);
													}
												}

												if (arg74
														&& arg75.size() > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												arg73 -= arg75.size();
											}

											if (arg51 != arg59.getId()) {
												arg75 = this.adjustBillDao
														.getExamSmsCount(arg71);
											} else {
												arg75 = this.adjustBillDao
														.getExamSmsCount();
											}

											if (arg75.size() > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg75.size()
														+ "张新调账单";

												for (arg76 = 0; arg76 < arg73; ++arg76) {
													if (arg76 < arg75.size()) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg75.get(arg76);
													}
												}

												if (arg74
														&& arg75.size() > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												arg73 -= arg75.size();
											}

											if (arg51 != arg59.getId()) {
												arg75 = this.transferBillDao
														.getExamSmsCount(arg71);
											} else {
												arg75 = this.transferBillDao
														.getExamSmsCount();
											}

											if (arg75.size() > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg75.size()
														+ "张新转账取款单";

												for (arg76 = 0; arg76 < arg73; ++arg76) {
													if (arg76 < arg75.size()) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg75.get(arg76);
													}
												}

												if (arg74
														&& arg75.size() > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												arg73 -= arg75.size();
											}

											if (arg51 != arg59.getId()) {
												arg75 = this.loanBillDao
														.getExamSmsCount(arg71);
											} else {
												arg75 = this.loanBillDao
														.getExamSmsCount();
											}

											arg76 = 0;
											int arg77 = 0;

											int arg78;
											for (arg78 = 0; arg78 < arg75
													.size(); ++arg78) {
												Object[] arg79 = (Object[]) arg75
														.get(arg78);
												if (arg79[0].toString().equals(
														"IN")) {
													++arg76;
												} else {
													++arg77;
												}
											}

											int arg80;
											Object[] arg81;
											if (arg76 > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg76
														+ "张新资金借入单";
												arg78 = 0;

												for (arg80 = 0; arg80 < arg75
														.size()
														&& arg78 < arg73; ++arg80) {
													arg81 = (Object[]) arg75
															.get(arg80);
													if (arg81[0].toString()
															.equals("IN")) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg81[1];
														++arg78;
													}
												}

												if (arg74 && arg76 > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												arg73 -= arg76;
											}

											if (arg77 > 0) {
												if (!arg66.equals("")) {
													arg66 = arg66 + "、";
												}

												arg66 = arg66 + arg77
														+ "张新资金借出单";
												arg78 = 0;

												for (arg80 = 0; arg80 < arg75
														.size()
														&& arg78 < arg73; ++arg80) {
													arg81 = (Object[]) arg75
															.get(arg80);
													if (arg81[0].toString()
															.equals("OUT")) {
														if (!arg72.equals("")) {
															arg72 = arg72 + "、";
														}

														arg72 = arg72
																+ arg81[1];
														++arg78;
													}
												}

												if (arg74 && arg77 > arg73) {
													arg72 = arg72 + "......";
													arg74 = false;
												}

												int arg9999 = arg73 - arg77;
											}

											if (!arg66.equals("")) {
												arg72 = "（" + arg72 + "）";
												content1 = arg59
														.getStafferName()
														+ "：有"
														+ arg66
														+ "等待你审核";
												this.createSystemMessage(
														arg59,
														shortEnSf.format(e)
																+ " 有" + arg66
																+ "待审核",
														content1
																+ arg72
																+ "["
																+ shortEnSf
																		.format(e)
																+ "]",
														this.businessBillDao,
														this.idGenerator);
												if (stafferList.getSmsFlag()
														.equals("Y") && canSms) {
													PageHelper
															.sendSms(
																	arg59.getMobile(),
																	arg59.getStafferName(),
																	content1
																			+ "["
																			+ shortEnSf
																					.format(e)
																			+ "]",
																	smsSign,
																	this.smsAlertDao,
																	this.idGenerator);
												}
											}
										}

										this.receiveBillDao.updateExamSms();
										this.payBillDao.updateExamSms();
										this.feeBillDao.updateExamSms();
										this.incomeBillDao.updateExamSms();
										this.transferBillDao.updateExamSms();
										this.adjustBillDao.updateExamSms();
										this.loanBillDao.updateExamSms();
									}
								}
							}

							if (content.equals("CYCLE")) {
								stafferList.setLastCheck(longEnSf.format(e));
							} else {
								stafferList.setLastCheck(sf.format(e));
							}

							this.smsAlertDao.update(stafferList);
						}
					}

					++commList;
				}
			} catch (Exception arg41) {
				arg41.printStackTrace();
			}

			try {
				EncCommonHelper
						.debug("************sms alert:thread sleeping...");
				Thread.sleep(120000L);
			} catch (Exception arg40) {
				;
			}
		}

	}

	private long[] getTsIdArr(long stafferId) {
		List utList = this.userPoDao.getListByStaffer(stafferId, "TS");
		long[] tsIdArr = new long[utList.size()];

		for (int k = 0; k < utList.size(); ++k) {
			tsIdArr[k] = ((UserPo) utList.get(k)).getPoId();
		}

		return tsIdArr;
	}

	private long[] getWcIdArr(long stafferId) {
		List uwList = this.userPoDao.getListByStaffer(stafferId, "WC");
		long[] wcIdArr = new long[uwList.size()];

		for (int k = 0; k < uwList.size(); ++k) {
			wcIdArr[k] = ((UserPo) uwList.get(k)).getPoId();
		}

		return wcIdArr;
	}

	private void createSystemMessage(Staffer sta, String msgTitle,
			String msgContent, BaseDao baseDao, IdGenerator idGen) {
		ArrayList stafList = new ArrayList();
		stafList.add(sta);
		PageHelper.sendMessage(msgTitle, msgContent, 0L, (UserBean) null,
				stafList, baseDao, idGen);
	}
}